package com.xing.controller;

import com.xing.DTO.LoginDTO;
import com.xing.DTO.UserDTO;
import com.xing.service.UserService;
import com.xing.utils.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @version 1.0
 * @Author Xing
 * @Date 2024/7/16 11:43
 */
@Tag(name = "登录")
@RestController
@RequestMapping("auth")
public class LoginController {

    @Autowired
    private UserService service;

    @Operation(summary = "登录")
    @PostMapping("login")
    public Result Login(@RequestBody LoginDTO dto) {
        return service.Login(dto);
    }

    @Operation(summary = "注册")
    @PostMapping("register")
    public Result Register(@RequestBody LoginDTO dto) {
        return service.Register(dto);
    }

    @Operation(summary = "获取当前用户信息")
    @GetMapping("me")
    public Result GetMe() {
        return service.GetMe();
    }

}
